package com.neusoft.neu24.nep.handler;

import com.neusoft.neu24.nep.dao.AuthorRepository;
import com.neusoft.neu24.nep.entity.Author;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;


@Component
public class AuthorHandler {
    private final AuthorRepository authorRepository;

    @Autowired
    public AuthorHandler(AuthorRepository authorRepository) {
        this.authorRepository = authorRepository;
    }

    public Mono<Author> save(Author author) {
        return  authorRepository.save(author) ;
    }

    public Mono<Author> findAuthorByName(  String name){
        return authorRepository.findAuthorByName(name);
    }

    public Flux<Author> findAll(){
        return authorRepository.findAll();
    }

}
